#!/usr/bin/python
# -*- coding: UTF-8 -*-
import my_array
num = 8
array_ptr = my_array.alloc_array(num)
array = my_array.uint_array.frompointer(array_ptr)
for i in range(num):
    array[i] = i
# 下面的两种方式A和B都可行
# A
str_inst = my_array.cdata(array_ptr, num * 4)
# B
str_inst = my_array.cdata(array, num * 4)
print repr(str_inst)
with open("/tmp/t0", 'wb') as f:
    f.write(str_inst)

my_array.free_array(array)

num = 10
str_inst = '\x22\x33\xAA\x55' * num
array_ptr = my_array.alloc_array(num+0)
array = my_array.uint_array.frompointer(array_ptr)
print repr(str_inst)
# 下面的两种方式A和B都可行
# A
#my_array.memmove(array_ptr, str_inst)
# B
my_array.memmove(array, str_inst)
for i in range(num):
    print "%08X" % array[i]

